<?php
$j=1;
$csv = "STT\tMã hàng\t   Danh mục   \t   Tên sản phẩm   \t   Mô tả\t Giá   \r\n";

if(count($products))
{
	foreach($products as $pro)
    {
    	$order_list = array(
    						'no'		=> $j
							,'product_id' 		=> $pro['Product']['id']
							,'category_name' 	=> $pro['Category']['name']
							,'product_name' 		=> $pro['Product']['name']
							,'product_description'		 => strip_tags($pro['Product']['description'])
							,'product_price' => $pro['Product']['price'] 
							
			);
 
		$csv .= join("\t", $order_list)."\r\n";
		$j++;
    }
}
$csv = chr(255).chr(254).mb_convert_encoding($csv, "UTF-16LE", "UTF-8");
 
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=" . date("Y-m-d") .
"_order_list.xls; size=".strlen($csv)); 

echo $csv;
exit();